package com.yy.controller;

import com.yy.param.UserRegisterParam;
import org.apache.catalina.User;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotEmpty;

/**
 * @author lyy
 * @date 2021/12/09
 */
@RestController
@RequestMapping("/user")
@Validated
public class UserController {

    @PostMapping("/register")
    public String register(@RequestBody @Validated UserRegisterParam param){
        return param.toString();
    }

    @GetMapping("/get/{userId}")
    public Long getUser(@Max (value = 10,message = "不能超过 10")@PathVariable Long userId){
        return userId;
    }

    @GetMapping("/get")
    public String getUser(@NotEmpty(message = "name 不能为空") String name,
                          @NotEmpty(message = "password 不能为空") String password){
        return name;
    }

    @GetMapping("/getUserRegister")
    public String getUserRegister(@Validated UserRegisterParam param){
        return param.toString();
    }

}
